﻿using System;
using System.ComponentModel.Composition;

namespace NDBGen.Descriptors.Columns.Tokens
{
    [MetadataAttribute]
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public sealed class ColumnTokenDescriptorAttribute : ColumnMetadataAttribute
    {
        public ColumnTokenDescriptorAttribute(params Type[] triggeredByTypes)
            : this(DataType.All, triggeredByTypes) { }

        public ColumnTokenDescriptorAttribute(DataType dataTypes, params Type[] triggeredByTypes)
            : base(typeof(IColumnTokenDescriptor), dataTypes)
        {
            this.TriggeredByTypes = triggeredByTypes;
            this.IsTriggered = triggeredByTypes != null && triggeredByTypes.Length > 0;
        }

        public Boolean HasValue { get; set; }

        public Boolean GeneratesWhenNotPresent { get; set; }

        public Boolean IsTriggered { get; set; }

        public Type[] TriggeredByTypes { get; set; }
    }
}